<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* #box::-webkit-scrollbar{
            display: none;
        } */
        #box {
            width: 200px;
            height: 200px;
            border: 1px solid transparent;
            background-color: #6ff;
            padding: 10px;
            margin: 50px;
            overflow-y: auto;
            /* display: none; */
        }

        .sub {
            height: 1000px;
            width: 100%;
            background-color: orange;
        }

        .active {
            background-color: pink !important;
            border-color: red !important;
        }
    </style>
</head>

<body>
    <div id="box" class="one two three">
        <div class="sub"></div>
    </div>
</body>
<script>
    var box = document.getElementById("box");
    console.dir(box);

    // clientWidth  clientHeight  元素的可视宽高  (content + padding)
    // offsetWidth  offsetHeight  元素的偏移宽高  (content + padding + border)
    // scrollWidth  scrollHeight  元素的实际宽高  

    // 优点: 
    // 属性存在于元素节点上 -> 快捷获取

    // 缺点:
    // 1. 只能取值 不能赋值  
    // 2. 对于隐藏的元素当前属性不生效,都是0   (通过属性取值时,为了获取最新的,会使页面回流 => 但是隐藏的元素不会触发回流,如果元素已经隐藏 => 无法获取实际值 => 0)

    // scrollLeft   scrollTop     滚动条距离元素左边/顶部的位置 (可以取值和赋值)

    console.log(box.clientWidth, box.clientHeight);
    console.log(box.scrollWidth, box.scrollHeight);
    console.log(box.scrollLeft, box.scrollTop);

    box.onscroll = function () {
        console.log(box.scrollLeft, box.scrollTop);
    }





</script>

</html>